package vn.vnvas.xoso.mienbac.thongke;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class thongkeAdapter extends ArrayAdapter<MenuThongKe>{
	
	private Context mContext;
	private ArrayList<MenuThongKe> mArrayList;
	
	public thongkeAdapter(Context context, int textViewResourceId,
			ArrayList<MenuThongKe> arrays) {
		super(context, textViewResourceId, arrays);
		
		this.mContext = context;
		this.mArrayList = arrays;

	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View menuView = convertView;
		if (menuView == null) {
			menuView = new LayoutMenuItem(mContext);
		}

		// lay tung phan tu mang tuong ung voi vi tri cua adapter
		MenuThongKe menu = mArrayList.get(position);
		if (menu != null) {
			// lay tung thanh phan cua item listview
			TextView tvMenu = ((LayoutMenuItem) menuView).menu;
			ImageView imgPicture = ((LayoutMenuItem) menuView).picture;
			TextView menu_id= ((LayoutMenuItem)menuView).menu_id;

			// set gia tri cho tung thanh phan cua item voi tung thuoc tinh cua
			// doi tuong mang
			tvMenu.setText(menu.menu);
			imgPicture.setImageBitmap(menu.picture);
			menu_id.setText(menu.menu_id);

		}

		return menuView;

	}
	
	
	

}
